<?php
$cs = Yii::app()->clientScript;
$cssCoreUrl = $cs->getCoreScriptUrl();
$cs->registerCoreScript('jquery.ui');
$cs->registerCssFile($cssCoreUrl . '/jui/css/base/jquery-ui.css');
$cs->registerScriptFile(BASE_URL . '/js/jquery_plus/jquery.form.js', CClientScript::POS_END);
$cs->registerScriptFile(BASE_URL . '/js/jquery_plus/qTip/jquery.qtip.min.js', CClientScript::POS_END);
$cs->registerCssFile(BASE_URL . '/js/jquery_plus/qTip/jquery.qtip.min.css');
$this->menu = array(
	array('label'=>'广告管理列表', 'url'=>array('admin')),
);
if(!empty($model['_id'])){
	$this->menu[] = array('label'=>'新建广告组', 'url'=>array('Edit'));
}
?>
<h2><a href="/manage/ad/admin">广告管理列表</a> > 广告编辑</h2>
<?php 
$this->beginWidget('CActiveForm', array(
	'id'			=> 'ad_form',
	'htmlOptions' 	=> array('class'=>'setting_form'),
));
?>
	<div class="setting_nav"></div>
	<dl class="setting_content">
		<dt>基本信息</dt>
		<dd>
			<strong>广告组名称：</strong>
			<?php echo YHtml::activeTextField($model, 'title', array('model'=>'Ad', 'rule'=>'^.{1,50}$', 'next_focus'=>''))?>
			<p>仅用于备注，建议使用简洁明了的名称</p>
		</dd>
		<dd>
			<strong>广告组代码：</strong>
			<?php echo YHtml::activeTextField($model, 'code', array('model'=>'Ad', 'rule'=>'^$|[_|a-z|A-Z|0-9]{1,50}$', 'next_focus'=>''))?>
			<p>用于模块调用，请使用字母、数字及下划线，不可重复</p>
		</dd>
		<dd>
			<strong>分类：</strong>
			<?php 
			$cates = isset($model['cate']) ? $model['cate'] : null;
			$this->widget('manage.widget.YSelectorWidget', array(
				'default_text' 	=> '点击设置分类',
				'name'			=> 'Ad[cate][]',
				'tpl' 			=> 'mutil_select',
				'options' 		=> AdCateModel::getCateOpts(false),
				'value'			=> $cates,
				'value_text'	=> AdCateModel::getName($cates, ','),
				'title'			=> '请选择分类',
			));
			?>
			<p>
				<?php 
				echo YHtml::link('添加广告分类', '/Manage/AdCate/Edit', array(
					'visible'	=> Yii::app()->user->v('manage@AdCateEdit')
				))
				?>
			</p>
		</dd>
		<dd>
			<strong>说明：</strong>
			<?php echo YHtml::activeTextArea($model, 'remark', array('model'=>'Ad', 'id'=>false, 'class'=>'ad_remark'))?>
		</dd>
		<dt>广告内容</dt>
		<dd>
			<?php 
			$this->renderPartial('_ad_item', array(
				'items' => isset($model['items'])?$model['items']:null,
				'thumb'	=> '100x100'
			));
			?>
		</dd>
		<dt>添加广告</dt>
		<dd class="add_item">
			<ul>
				<li>
					<?php 
					$this->widget('manage.widget.UploaderWidget',array(
						'has_main_picture' 	=> false, 
						'pictures' 			=> null,
						'thumb'				=> '100x100',
						'tpl'				=> 'simple',
						'id'				=> 'ad_uploader',
						'default_onload_js'	=> 'y_on_uploaded_ad_image_list'
					));
					?>
					<p>（点击添加图片广告）</p>
				</li>
				<li>
					<a href="javascript:void(0)" id="add_text_ad">点击添加文字广告</a>
				</li>
			</ul>
		</dd>
	</dl>
	<div class="buttons right">
		<?php echo YHtml::activeHiddenField($model, '_id', array('model'=>'Ad'))?>
		<input type="button" class="button save_btn" value="保存"/>
	</div>
<?php $this->endWidget(); ?>